package com.acargil.sudoku.view.listeners;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import com.acargil.sudoku.model.ISudokuEngine;
import com.acargil.sudoku.view.ISudokuView;

public class ClearListener implements ActionListener {

	private static ActionListener instance = null; 
    private ISudokuEngine model;
    private ISudokuView view;
    
    protected ClearListener(ISudokuEngine model, ISudokuView view) {
        this.model = model;
        this.view = view;
    }
    
    public void actionPerformed(ActionEvent e) {
        model.clearAllCellValues();
        view.setAllCells(model.getAllCellValues());
    }

	public static ActionListener getInstance(ISudokuEngine model, ISudokuView view) {
		if (instance == null) {
			instance = new ClearListener(model, view);
		}
		
		return instance;
	}
}